﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System.Net.Http;
using Water.Model;
using System.Net.Http.Headers;
using System.Collections.Generic;

namespace Water.Rest.UnitTest
{
    [TestClass]
    public class BigValveOperateUnitTest
    {
        string basUrl = "http://localhost:46518/"; //"http://180.169.20.194:8015/"; //;

        [TestMethod]
        public void GetBigValveOperate()
        {
            string url = basUrl + "GetBigValveOperate/AEEEFASDF";
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
            var mr = JsonConvert.DeserializeObject<BigValveOperate>(response);
        }

        [TestMethod]
        public void EditBigValveOperate()
        {
            string url = basUrl + "GetBigValveOperate/AEEEFASDF";
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
            BigValveOperate mr = JsonConvert.DeserializeObject<BigValveOperate>(response);

            url = basUrl + "EditBigValveOperate";
            mr.CloseDt = Convert.ToDateTime("2013-07-04 09:30:00");
            var requestJson = JsonConvert.SerializeObject(mr);
            HttpContent httpContent = new StringContent(requestJson);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            // var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;
        }

        [TestMethod]
        public void GetSmallValveOperate()
        {
            string url = basUrl + "GetSmallValveOperate/EFADDADF";
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
            var mr = JsonConvert.DeserializeObject<SmallValveOperate>(response);
        }

        [TestMethod]
        public void EditSmallValveOperate()
        {
            string url = basUrl + "GetSmallValveOperate/EFADDADF";
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
            SmallValveOperate mr = JsonConvert.DeserializeObject<SmallValveOperate>(response);

            url = basUrl + "EditSmallValveOperate";
            mr.CloseDt = Convert.ToDateTime("2013-07-04 09:30:00");
            mr.ZhuanCount = 3;
            var requestJson = JsonConvert.SerializeObject(mr);
            HttpContent httpContent = new StringContent(requestJson);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            // var httpClient = new HttpClient();
            var responseJson = httpClient.PostAsync(url, httpContent)
                .Result.Content.ReadAsStringAsync().Result;
        }

        [TestMethod]
        public void GetChartBuildMana()
        {
            string pValue = "F02001";
            string url = basUrl + "GetChartBuildMana/" + pValue + "/admin";
            var httpClient = new HttpClient();
            var response = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
            var mr = JsonConvert.DeserializeObject<ChartBuildMana>(response);
        }
    }
}